package com.cloudcc.mobile.dao.impl;

import com.cloudcc.cloudframe.net.ResultCallBack;
import com.cloudcc.cloudframe.net.async.BeanRequest;
import com.cloudcc.mobile.dao.BaseEngine;
import com.cloudcc.mobile.entity.MultipleListmodel;
import com.cloudcc.mobile.entity.approval.ApprovalModel;
import com.cloudcc.mobile.entity.approval.TaskApprovalHistoryModel;
import com.cloudcc.mobile.entity.approval.TaskManagementModel;
import com.google.gson.JsonObject;
import com.loopj.android.http.RequestParams;

import org.json.JSONObject;

import java.util.List;

/**
 * 
 * @author lhy 审批部分
 */
public class ApprovalEngineImpl extends BaseEngine {
	// 审批历史列表
	public void getApprovalHistoryList(JsonObject json,
			ResultCallBack<List<ApprovalModel>> listener) {
		BeanRequest<List<ApprovalModel>> request = new BeanRequest<List<ApprovalModel>>() {
		};
		request.setResultListener(listener);
		sendPost(json.toString(), request, "getApprovalHistory", true);
	}

	// 调回批准请求
	public void ApprovalRebackRequest(JSONObject json,
			ResultCallBack<Object> listener) {
		BeanRequest<Object> request = new BeanRequest<Object>() {
		};
		request.setResultListener(listener);
		sendPost(json, request, "getChatterUserInfo", true);
	}

	// 重新分配
	public void ApprovalAgainRequest(JSONObject json,
			ResultCallBack<Object> listener) {
		BeanRequest<Object> request = new BeanRequest<Object>() {
		};
		request.setResultListener(listener);
		sendPost(json, request, "getChatterUserInfo", true);
	}

	// 进行审批
	public void ApprovalGoingApprovalRequest(JSONObject json,
			ResultCallBack<Object> listener) {
		BeanRequest<Object> request = new BeanRequest<Object>() {
		};
		request.setResultListener(listener);
		sendPost(json, request, "getChatterUserInfo", true);
	}

	// 小列表
	public void GetMultipleRequest(JsonObject json,
			ResultCallBack<MultipleListmodel> resultCallBack) {
		BeanRequest<MultipleListmodel> request = new BeanRequest<MultipleListmodel>() {
		};
		request.setResultListener(resultCallBack);
		sendPost(json, request, "getRelationDataByRelationId", true);
	}

	public void GetManagementTask(JSONObject json,
			ResultCallBack<List<TaskManagementModel>> resultCallBack) {
		BeanRequest<List<TaskManagementModel>> request = new BeanRequest<List<TaskManagementModel>>() {
		};
		request.setResultListener(resultCallBack);
		sendPost(json, request, "getRelationDataByRelationId", true);
	}

	// 审批列表
	public void GetManagementTask(String userId,
			ResultCallBack<List<TaskManagementModel>> resultCallBack) {
		BeanRequest<List<TaskManagementModel>> request = new BeanRequest<List<TaskManagementModel>>() {
		};
		request.setResultListener(resultCallBack);
		RequestParams params = new RequestParams();
		params.put("userId", userId);
		sendPost(params, "getApprovalPaddingList", request);
	}

	/**
	 * 1.sv_num 每页显示记录数 2.sv_page 第几页 3.prefix 对象前缀
	 * 
	 * @param userId
	 * @param resultCallBack
	 */
	// 新版待审批
	public void GetManagementTask_z(String userId,int num,
			ResultCallBack<JsonObject> resultCallBack) {
		BeanRequest<JsonObject> request = new BeanRequest<JsonObject>() {
		};
		request.setResultListener(resultCallBack);
		RequestParams params = new RequestParams();
		params.put("sv_num", 15*num+"");
		sendPost(params, "getmangeAllAppRequest", request);
	}
	// 新版待审批详情
	public void GetManagementTask_z(String userId,int num,String recordId,
									ResultCallBack<JsonObject> resultCallBack) {
		BeanRequest<JsonObject> request = new BeanRequest<JsonObject>() {
		};
		request.setResultListener(resultCallBack);
		RequestParams params = new RequestParams();
		params.put("sv_num", 15*num+"");
		params.put("record_id", recordId);
		sendPost(params, "getmangeAllAppRequest", request);
	}

	// 加载更多
	public void GetManagementTask_jzgd(int sv_page, String prefix,
			ResultCallBack<JsonObject> resultCallBack) {
		BeanRequest<JsonObject> request = new BeanRequest<JsonObject>() {
		};
		request.setResultListener(resultCallBack);
		RequestParams params = new RequestParams();
		params.put("sv_page", sv_page);
		params.put("sv_num","15");
		params.put("prefix", prefix);
		sendPost(params, "ajaxShowAllPendingHisNew", request);
	}

	// 审批状态列表getApprovalHistory
	public void getApprovalHistory(String relatedId,
			ResultCallBack<List<TaskApprovalHistoryModel>> resultCallBack) {
		BeanRequest<List<TaskApprovalHistoryModel>> request = new BeanRequest<List<TaskApprovalHistoryModel>>() {
		};
		request.setResultListener(resultCallBack);
		RequestParams params = new RequestParams();
		params.put("relatedId", relatedId);
		sendPost(params, "getApprovalHistory", request);
	}

}
